package com.liliudong.template.biz.mapper.sys;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liliudong.template.common.entity.sys.SysDictItem;
import com.liliudong.template.common.vo.sys.SysDictItemListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 系统-字典值 Mapper
 *
 * @author ldli5
 * @date 2024-07-04 14:57:53
 */
@Mapper
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {

	/**
	 * 列表忽略数据权限
	 *
	 * @param dictCode dict码
	 * @return {@link List }<{@link SysDictItemListVO }>
	 */
	@InterceptorIgnore(dataPermission = "true")
	@Select("""
			select sdi.id,
			       sdi.dict_id,
			       sdi.label,
			       sdi.value,
			       sdi.created_at,
			       sdi.created_by,
			       sdi.created_from,
			       sdi.updated_at,
			       sdi.updated_by,
			       sdi.deleted
			from sys_dict_item sdi
			         inner join sys_dict sd on sdi.dict_id = sd.id and sd.deleted = 0
			where sd.code = #{dictCode}
			  and sdi.deleted = 0
			""")
	List<SysDictItemListVO> selectListIgnoreDataPermission(String dictCode);
}
